import { createStore, combineReducers, applyMiddleware } from './myredux'
// import thunk from 'redux-thunk'
import { thunk, logger } from './midWares'
function CountReducer(state, action) {
  state = state || {
    count: 100
  }
  if (action.type == 'changeCount') {
    state.count = action.count
  }
  return {
    ...state
  }
}
function colorReducer(state, action) {
  state = state || {
    color: 'red'
  }
  if (action.type == 'changeColor') {
    state.color = action.color
  }
  return {
    ...state
  }
}

let rootReducer = combineReducers({
  countState: CountReducer,
  colorState: colorReducer
})
// state:{countState:{count:100},colorState:{color:'red'}}

let store = createStore(rootReducer, applyMiddleware(logger, thunk))//{getState,subscribe,dispatch}
export default store